package com.qianfeng.smartplatform.pojo;

import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

public class Category implements Serializable,CheckEmptyInterface {
    private Integer cId;

    private String categoryName;

    private String txCommand;

    private String rxCommand;

    private String commandName;

    private Short status;

    private Date createTime;

    private String createBy;

    private Date updateTime;

    private String updateBy;


    private List<Device> deviceList;

    @Override
    public boolean isEmpty(CheckType checkType) {
        switch (checkType) {
            case ADD:
                return !StringUtils.hasText(categoryName)||!StringUtils.hasText(createBy);
            case UPDATE:
                //更新的时候必须有更新者,并且至少传递一个列的值,如果传递的是状态必须是有效值
                return !StringUtils.hasText(updateBy)||(!StringUtils.hasText(categoryName)&&!StringUtils.hasText(txCommand)&&!StringUtils.hasText(rxCommand)&&!StringUtils.hasText(commandName)&&(ObjectUtils.isEmpty(status)||status<0));
        }
        return CheckEmptyInterface.super.isEmpty(checkType);
    }

    public List<Device> getDeviceList() {
        return deviceList;
    }

    public void setDeviceList(List<Device> deviceList) {
        this.deviceList = deviceList;
    }

    private static final long serialVersionUID = 1L;

    public Integer getcId() {
        return cId;
    }

    public void setcId(Integer cId) {
        this.cId = cId;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName == null ? null : categoryName.trim();
    }

    public String getTxCommand() {
        return txCommand;
    }

    public void setTxCommand(String txCommand) {
        this.txCommand = txCommand == null ? null : txCommand.trim();
    }

    public String getRxCommand() {
        return rxCommand;
    }

    public void setRxCommand(String rxCommand) {
        this.rxCommand = rxCommand == null ? null : rxCommand.trim();
    }

    public String getCommandName() {
        return commandName;
    }

    public void setCommandName(String commandName) {
        this.commandName = commandName == null ? null : commandName.trim();
    }

    public Short getStatus() {
        return status;
    }

    public void setStatus(Short status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy == null ? null : createBy.trim();
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy == null ? null : updateBy.trim();
    }
}